﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace IslandInterloper.Engine
{
    internal class AvatarIslands : GameClientCollectionIntKeyed<AvatarIsland>
    {
        public void Locate(int theIslandID, int theDay)
        {
            if (this[theIslandID] == null)
            {
                collection.Add(theIslandID, new AvatarIsland(Game, theIslandID, theDay));
            }
        }
        public void Visit(int theIslandID, int theDay)
        {
            Locate(theIslandID, theDay);
            collection[theIslandID].Visit(theDay);
        }
        public void ToggleBookMark(int theIslandID)
        {
            if (this[theIslandID] != null)
            {
                collection[theIslandID].ToggleBookMark();
            }
        }
        public void Annotate(int theIslandID, string theNote)
        {
            if (this[theIslandID] != null)
            {
                collection[theIslandID].Annotate(theNote);
            }
        }
        internal AvatarIslands(Game theGame)
            : base(theGame)
        {
        }
        internal AvatarIslands(Game theGame, XElement element)
            : base(theGame,element)
        {
        }
        protected override AvatarIsland LoadItemFromXElement(XElement element)
        {
            return new AvatarIsland(Game, element);
        }
        protected override XName KeyToXName(int theKey)
        {
            return GameXNames.knownIsland;
        }
    }
}
